/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software Foundation,
 *    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

package JET.Actions;

import JET.Centers.ControlCenter;
import JET.Scene;
import JET.physics.steering.Torque;
import java.util.ArrayList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 *
 * @author 057Ry
 */
public class SetTorquesOrientation extends Action
{
    private ArrayList<Torque> torquesList;
    private double orient;

    /**
     * Sets torque orientation.
     * -1 is Counter Clockwise
     *  1 is Clockwise
     * @param t torque
     * @param o orientation (-1 or 1)
     */
    public SetTorquesOrientation(String name, ArrayList<Torque> tList, double o)
    {
        super(name);
        torquesList = new ArrayList<Torque>(tList);
        orient = o;
    }
    
    public void addTorque(Torque t)
    {
        torquesList.add(t);
    }
    public void addToriques(ArrayList<Torque> tList)
    {
        torquesList.addAll(tList);
    }
    public void clearTorques()
    {
        torquesList.clear();
    }

    @Override
    public void call()
    {
        for(Torque t : torquesList)
            t.setValue( Math.abs(t.getValue())*orient );
    }

    @Override
    public String toString()
    {
        return this.getClass().getName();
    }

    @Override
    public Element getXMLRepresentation(Document doc, Scene scene) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
